package com.zhuchang.self_rpc.test.consumer;

import com.zhuchang.self_rpc.test.client.RpcClient;
import com.zhuchang.self_rpc.test.common.RpcFuture;
import com.zhuchang.self_rpc.test.proxy.RpcAsyncProxy;

import java.util.concurrent.ExecutionException;

/**
 * @Author RenPu
 * @Date 2021/8/19 10:57
 * @Version 1.0
 * @Description:
 **/
public class ConsumerStarter {

    public static void sync() {

        RpcClient rpcClient = new RpcClient();
        rpcClient.initClient("127.0.0.1:8848", 3000);
        HelloService helloService = rpcClient.inovkeSync(HelloService.class);
        String result = helloService.hello("王五！！！");
        String result2 = helloService.hello(new User("sunsi   465465465"));
        System.out.println(result2 + "同步方法打印的结果值    " + result);

    }


    public static void Async() throws InterruptedException, ExecutionException {

        RpcClient rpcClient = new RpcClient();
        rpcClient.initClient("127.0.0.1:8848", 3000);
        RpcAsyncProxy rpcAsyncProxy = rpcClient.inovkeAsync(HelloService.class);

        RpcFuture future = rpcAsyncProxy.call("hello", "li4....");
        RpcFuture future1 = rpcAsyncProxy.call("hello", new User("赵六"));
        System.out.println("结果值 11111111111111   " + future.get());
        System.out.println("结果值 22222222222222   " + future1.get());

    }


    public static void main(String[] args) throws Exception {
        Async();
    }


}
